<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>设备管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_hnvvzy2r2u.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all">


</head>

<body>
    <div style="margin:30px 0 0 30px;width:80%;height:80%">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">条形码</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="id" id="id" style="display: none">
                    <span class="layui-form-label" id="sno" style="margin-left:-40px"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">异常内容</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" id="context" readonly style="resize:none"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">处理结果</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="result" id="result" style="resize:none"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="add">处理</button>
                    <button class="layui-btn layui-btn-primary" id="close">取消</button>
                </div>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'user'], function() {
            var $ = layui.$,
                setter = layui.setter,
                admin = layui.admin,
                form = layui.form,
                router = layui.router(),
                search = router.search;
            form.render();

            form.on('submit(add)', function(obj) {
                admin.req({
                    url: "../../../Service/saveException",
                    type: "post",
                    datatype: "json",
                    data: obj.field,
                    success: function(res) {
                        if (res.data == "ok") {
                            layer.msg('保存成功', {
                                offset: 'auto',
                                icon: 1,
                                time: 1500,
                                end: function() {
                                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index); // 关闭layer
                                    $("#f5", parent.document).click();
                                }
                            })
                        } else if (res == '无权限') {
                            layer.msg('无权限，保存失败', {
                                offset: 'auto',
                                icon: 2,
                                time: 1000,
                                end: function() {
                                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index);
                                }
                            })
                        } else {
                            layer.msg('保存失败', {
                                offset: 'auto',
                                icon: 2,
                                time: 1000
                            })
                        }
                    },
                    error: function(res) {
                        layer.msg('保存失败', {
                            offset: 'auto',
                            icon: 2,
                            time: 1000
                        })
                    }
                })

            });
            $("#close").on("click", function() {
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index); // 关闭layer
            });
        });
    </script>

</body>

</html>